import { create } from 'zustand'
import { subscribeWithSelector } from 'zustand/middleware'

export default create(subscribeWithSelector((set) => {
  return {
    visible: undefined,

    updateVisible: (target) => {
      set(state => {
        return {visible: target}
      })
    },

    // 剩余游戏次数
    games: 0,

    env: undefined,

    updateENV: (env) => {
      set(state => {
        return {env}
      })
    },

    // 剩余抽奖次数
    lotterys: 0,

    update: (key, val) => {
      set(state => {
        return {
          [key]: val
        }
      })
    },
  }
}))